/**计算器**/
var clearText = false;
var fnum=0;
function getNum(num){
	//var result1 = document.getElementById("result");
	  var result1 = $("#jsq-result");
		if(clearText){			//判断是否要清屏
		//result1.value="";	
		$("#jsq-result").html("");
		clearText = false;
		}
	if(num=="="){				//如果输入的是"="，则计算，并输出
	   try{
		//result1.value =eval(result1.value);
		   var data = eval(result1.html());
		   result1.html(data);
		clearText = true;		//清屏
		}catch(e){
		 // result1.value="NaN";
		  result1.html("NaN");
		}
	}
	if(num!="="){				//如果不是"="，则继续输入
	    /* if(result1.value=="NaN"){
		    result1.value=num;
		 }else {
		    result1.value+=num;
		 }*/
		var data = result1.html();
		if(data=="NaN"){
		    result1.html(num);
		 }else {
		    data+=num;
		    result1.html(data);
		 }
	     
	}

}

function getNumf(num){
   // var result1 = document.getElementById("result");
    var result1 = $("#jsq-result");
    var data =  result1.html();
	if(data==""){
		if(num=="="){
			clearText = false;
			return false;
		}else if(num=="-"){
		   if(fnum==1){
		      clearText = false;
			  return false;
		   }else{
		      result1.value=num;
			  return false;
		   }
		}else if(num=="*"){
			clearText = false;
			return false;
		}else if(num=="/"){
			clearText = false;
			return false;
		}else if(num=="+"){
			clearText = false;
			return false;
		}
	}else{
	   getNum(num);   
	}
		
}

function clearNum(){
    /*var result1 = document.getElementById("result");
    result1.value="";	*/
	var result1 = $("#jsq-result");
	result1.html("");
	clearText = false;
}
var divEditorID="";
/**复制
 * */
function copyFrame(){
	var newT = window.frames[0].document.selection.createRange();
	newT.execCommand('Copy','true','null');
}
/**
* 粘贴
*
* Pass a layout-options object, and the pane/key you want to display
*/
function pasteCopy(){
	divEditorID = window.frames[0].inputId;
	  if(divEditorID!=""&&divEditorID!=null){
        newT=window.frames[0].document.selection.createRange();
	    var doc=  window.frames[0].document.getElementById(divEditorID);
		var data = clipboardData.getData("Text");
	    insertCom(doc,data);    
		}
}
/**
* 剪切
*
* Pass a layout-options object, and the pane/key you want to display
*/
function cutCopy(){
	 divEditorID = window.frames[0].inputId;
	 if(divEditorID!=""&&divEditorID!=null){
		var doc = getDoc(divEditorID);
		var str = doc.html();
		var length = str.length;
        newT=window.frames[0].document.selection.createRange();
		var snewT = newT.text;
		document.execCommand("Copy");
		newT.text="";
		doc.focus();
	}
}


function insertCom(myField,myValue){
   if (document.selection) {
    myField.focus();
    var sel = window.frames[0].document.selection.createRange();
    sel.text = myValue;
    sel.select();
  } 
}
function getDoc(id){
	//return window.frames[0].document.getElementById(id);
	return $(window.frames[0].document).find("#"+id);
}